package com.qfedu.stussm.controller;

import com.qfedu.stussm.dto.JclassDto;
import com.qfedu.stussm.entity.Jclass;
import com.qfedu.stussm.service.intf.JclassService;
import com.qfedu.stussm.vo.PageBeanVo;
import com.qfedu.stussm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("api/jclass/")
public class JclassController {
    @Autowired
    private JclassService service;
    @PostMapping("add.do")
    public R add (Jclass jclass) {
        System.out.println(jclass);
        return service.add(jclass);
    }
    @GetMapping("list.do")
    public PageBeanVo selectAll (String name, int page, int limit) {
        System.out.println(name);
        return service.selectAll(name, page, limit);
    }
    @PostMapping("del.do")
    public R delete (Integer id) {
        return service.delete(id);
    }
    @PostMapping("update.do")
    public R update (JclassDto jclass) {
        System.out.println(jclass);
        return service.update(jclass);
    }
    //导出Excel
    @GetMapping("download.do")
    public void download(HttpServletResponse response) throws IOException {
        service.createExcel(response);
    }
    //批量删除
    @PostMapping("delmany.do")
    public R delMany (Integer[] ids) {
        return service.delMany(ids);
    }
}
